package com.lc202408;

import java.util.ArrayList;
import java.util.List;

public class Solution448 {
    public List<Integer> findDisappearedNumbers(int[] nums) {
        int length = nums.length;
        for (int num : nums) {
            // 已经存在数的位置
            int i = (num - 1) % length;
            // 防止修改值对之后的影响
            nums[i] += length;

        }
        List<Integer> res = new ArrayList<>();
        for (int i = 0; i < length; i++) {
            if (nums[i] <= length) {
                res.add(i + 1);
            }
        }
        return res;
    }
}
